#include "stdafx.h"

#ifndef DLL_BBADDON_CPP
#define DLL_BBADDON_CPP

#include "bbAddon.h"

typedef unsigned char uchar;
typedef uchar * achar;

const int TobbObject_old(void*obj) {return rcast_i(obj);};

BBAEXPcfloat Clamp(float v, float min,float max)
{
	if (v<min) return min;
	if (v>max) return max;
	return v;
};

BBAEXPcfloat RadToDeg(const float a){return a*_RadToDeg;};

BBAEXPcfloat DegToRad(const float a){return a*_DegToRad;};

BBAEXPcfloat Min( const float a, const float b )
{if (b<a) {return b;};return a;};

BBAEXPcfloat Max( const float a, const float b )
{if (b>a) {return b;};return a;};

BBAEXPcfloat LinearInterp ( const float a, const float b, const float rate )
{return a+(b-a)*rate;};

BBAEXPcfloat CosInterp ( const float a, const float b, const float rate )
{return (a+((1-cosf(rate*PI))*.5f)*(b-a));};

BBAEXPcfloat CubicInterp(const float a,const float b,const float c,const float d,const float rate)
{return (((d-c-a+b)*rate+(a+a-b-b-d+c))*rate+c-a)*rate+b;}


BBAEXPint TypePointer(const int type){ return type; }
BBAEXPint FieldPointer(const int type, const int var_index){ return type+var_index; }
BBAEXPint FieldArrayPointer(const int *type, const int var_index){ return type[var_index]; }


#endif //DLL_BBADDON_CPP